package com.jyy.prefabricated.service.impl;

import com.jyy.prefabricated.entity.ExamCertificate;
import com.jyy.prefabricated.mapper.ExamCertificateMapper;
import com.jyy.prefabricated.service.ExamCertificateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 考试证书表(ExamCertificate)表服务实现类
 *
 * @author mrl
 * @since 2021-07-20 14:49:35
 */
@Service("examCertificateService")
public class ExamCertificateServiceImpl implements ExamCertificateService {
    @Resource
    private ExamCertificateMapper examCertificateDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ExamCertificate queryById(Integer id) {
        return this.examCertificateDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ExamCertificate> queryAllByLimit(int offset, int limit) {
        return this.examCertificateDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param examCertificate 实例对象
     * @return 实例对象
     */
    @Override
    public ExamCertificate insert(ExamCertificate examCertificate) {
        this.examCertificateDao.insert(examCertificate);
        return examCertificate;
    }

    /**
     * 修改数据
     *
     * @param examCertificate 实例对象
     * @return 实例对象
     */
    @Override
    public ExamCertificate update(ExamCertificate examCertificate) {
        this.examCertificateDao.update(examCertificate);
        return this.queryById(examCertificate.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.examCertificateDao.deleteById(id) > 0;
    }
}